package com.rt.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rt.common.annotation.Log;
import com.rt.common.core.controller.BaseController;
import com.rt.common.core.domain.AjaxResult;
import com.rt.common.enums.BusinessType;
import com.rt.system.domain.RtAssemblyInfo;
import com.rt.system.service.IRtAssemblyInfoService;
import com.rt.common.utils.poi.ExcelUtil;
import com.rt.common.core.page.TableDataInfo;

/**
 * 组卷策略信息Controller
 * 
 * @author Yg
 * @date 2022-05-05
 */
@RestController
@RequestMapping("/system/assembly")
public class RtAssemblyInfoController extends BaseController
{
    @Autowired
    private IRtAssemblyInfoService rtAssemblyInfoService;

    /**
     * 查询组卷策略信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(RtAssemblyInfo rtAssemblyInfo)
    {
        startPage();
        List<RtAssemblyInfo> list = rtAssemblyInfoService.selectRtAssemblyInfoList(rtAssemblyInfo);
        return getDataTable(list);
    }

    /**
     * 导出组卷策略信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "组卷策略信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RtAssemblyInfo rtAssemblyInfo)
    {
        List<RtAssemblyInfo> list = rtAssemblyInfoService.selectRtAssemblyInfoList(rtAssemblyInfo);
        ExcelUtil<RtAssemblyInfo> util = new ExcelUtil<RtAssemblyInfo>(RtAssemblyInfo.class);
        return util.exportExcel(list, "组卷策略信息数据");
    }

    /**
     * 获取组卷策略信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rtAssemblyInfoService.selectRtAssemblyInfoById(id));
    }

    /**
     * 新增组卷策略信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "组卷策略信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RtAssemblyInfo rtAssemblyInfo)
    {
        rtAssemblyInfo.setCreateBy(String.valueOf(getUserId()));
        return toAjax(rtAssemblyInfoService.insertRtAssemblyInfo(rtAssemblyInfo));
    }

    /**
     * 修改组卷策略信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "组卷策略信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RtAssemblyInfo rtAssemblyInfo)
    {
        return toAjax(rtAssemblyInfoService.updateRtAssemblyInfo(rtAssemblyInfo));
    }

    /**
     * 修改组卷策略信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "组卷策略信息", businessType = BusinessType.UPDATE)
    @PutMapping("/editStatus")
    public AjaxResult editStatus(@RequestBody RtAssemblyInfo rtAssemblyInfo)
    {
        return toAjax(rtAssemblyInfoService.updateRtAssemblyStatus(rtAssemblyInfo));
    }

    /**
     * 删除组卷策略信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "组卷策略信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(rtAssemblyInfoService.deleteRtAssemblyInfoById(id));
    }
}
